package com.mydubbo.proxy;

import java.lang.reflect.InvocationHandler;
import java.lang.reflect.Method;
import java.lang.reflect.Proxy;

public class JdkProxyFactory extends BaseProxyFactory {
	
	@Override
	public Object getProxy(Class<?> clazz) {
		Object proxy = Proxy.newProxyInstance(this.getClass().getClassLoader(), clazz.getInterfaces(), new InvocationHandler() {
			
			@Override
			public Object invoke(Object proxy, Method method, Object[] args) throws Throwable {
				Class<?> clazz = proxy.getClass().getInterfaces()[0];
				return invoker.invoke(clazz, method, args);
			}
		});
		return proxy;
	}

}
